<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Document</title>
  </head>
  <body>
    <script>
      var arr = ['apple', 'banana', 'orange', 'pear'];
      // 调用前面编写的getRandom()函数获取随机数
      console.log(arr[getRandom(0, arr.length - 1)]);
    </script>
  </body>
</html>